<template>
  <d2-container>
    <div style="width:80%;">
      <el-input
        placeholder="请输入店铺名字"
        v-model="getEvaluatelist.shop_name"
        style="width:150px;"
        clearable>
      </el-input>
      <el-input
        placeholder="请输入订单号"
        v-model="getEvaluatelist.orderevalute"
        style="width:150px;;margin-left:10px;"
        clearable>
      </el-input>
      <el-input
        placeholder="请输入旺旺号"
        v-model="getEvaluatelist.ww_name"
        style="width:150px;;margin-left:10px;"
        clearable>
      </el-input>
      <el-date-picker
        v-model="getEvaluatelist.dates"
        type="daterange"
        value-format="YYYY-MM-dd"
        range-separator="至"
        style="margin-left:20px;"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
      <el-button type="primary" style="margin-left:20px;" @click="OnSearch()">查询</el-button>
    </div>
    <el-table
      :data="tableData"
      border
      style="width: 100%;margin-top:20px;">
      <el-table-column
        prop="baby_id"
        width="130"
        label="宝贝ID">
      </el-table-column>
      <el-table-column
        prop="brushhands_tbname"
        width="100"
        label="买手旺旺">
      </el-table-column>
      <el-table-column
        prop="task_shopname"
        width="130"
        label="店铺名字">
      </el-table-column>
      <el-table-column
        prop="task_bjmoney"
        width="100"
        label="本金">
      </el-table-column>
      <el-table-column
        prop="task_order"
        width="150"
        label="订单号">
      </el-table-column>
      <el-table-column
        prop="screenshot"
        label="评价图">
        <template slot-scope="scope">
          <viewer v-if="scope.row.screenshot!=''">
            <img :src="scope.row.screenshot" style="width:100px;height:100px;" alt="">
          </viewer>
          <span v-else>暂无图片</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="task_class"
        label="订单类型">
        <template slot-scope="scope">
          <span v-if="scope.row.task_class == 'dy'" style="color:purple;font-weight:600;font-size:18px">抖音单</span>
          <span v-if="scope.row.task_class == 'gy'" style="color:red;font-weight:600;font-size:18px">隔夜单</span>
          <span v-if="scope.row.task_class == 'pj'" style="color:#409eff;font-weight:600;font-size:18px">评价单</span>
          <span v-if="scope.row.task_class == 'll'" style="color:#67c23a;font-weight:600;font-size:18px">浏览单</span>
          <span v-if="scope.row.task_class == 'pt'" style="color:#e6a23c;font-weight:600;font-size:18px">普通单</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="title"
        width="450"
        label="评价内容">
      </el-table-column>
      <el-table-column
        prop="create_time"
        label="创建时间">
      </el-table-column>
      <el-table-column
        label="审核">
        <template slot-scope="scope">
          <el-button type="primary" @click="PassEvaluate(scope.row)">通过</el-button>
          <el-button type="danger" @click="RefuseEvaluate(scope.row)">拒绝</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @current-change="handleCurrentChange" @size-change="handleSizeChange" :current-page.sync="page"
                   :page-sizes="[10,20, 30, 40, 50]"
                   :page-size="pageSize" background layout="total, sizes, prev, pager, next, jumper" :total="count"
                   style="text-align:right;margin:10px 0;">
    </el-pagination>
  </d2-container>
</template>

<script>
import {reviewEvaluate,evaluateReview} from "@/api/sys.login";
export default {
  name: "index",
  data() {
    return {
      tableData: [],
      count: 0,
      page: 1,
      pageSize: 10,
      loading: false,
      getEvaluatelist: {
        page: 1,
        page_size: 5,
        orderevalute: "",
        shop_name: "",
        ww_name: "",
        dates: "",
      },
    }
  },
  methods: {
    handleSizeChange(val) {
      this.getEvaluatelist.pageSize = val
      this.OnSearch()
    },
    handleCurrentChange(val) {
      this.getEvaluatelist.page = val
      this.OnSearch()
    },
    //通过
    PassEvaluate(row){
      console.log(row);
      let params = {
        ce_id:row.ce_id,
        task_id:row.id,
      }
      evaluateReview(params).then((res)=>{
        console.log(res);
        this.reviewEvaluates()
      })
    },
    //拒绝
    RefuseEvaluate(row){
      let params = {
        ce_id:row.ce_id,
        task_id:row.id,
      }
      evaluateReview(params).then((res)=>{
        console.log(res);
        this.reviewEvaluates()
      })
    },
    OnSearch() {
      this.reviewEvaluates()
    },
    reviewEvaluates() {
      this.loading = true
      let params = {
        time_arr: this.getEvaluatelist.time_arr,//时间筛选
        page: this.getEvaluatelist.page,
        page_size: this.getEvaluatelist.page_size,
        shop_name: this.getEvaluatelist.shop_name, //店铺名字
        order: this.getEvaluatelist.order, //订单号
        ww_name: this.getEvaluatelist.ww_name //旺旺号
      }
      reviewEvaluate(params).then((res) => {
        if (res.status == 200) {
          this.loading = false
          this.tableData = res.data
          this.count = res.count
          console.log(res.data);
        }
      })
    }
  },
  created() {
    this.reviewEvaluates()
  }
}
</script>

<style scoped>

</style>
